package com.itggm.controller;


import com.itggm.Result.ResponseResult;
import com.itggm.dto.LogsExportDTO;
import com.itggm.dto.LogsPageDTO;
import com.itggm.service.LogInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.List;

 /**
  * @Author: ggm
  * @date:  2025/1/2
  */
 @Slf4j
@RestController
@RequestMapping("logs")
public class LogInfoController {

    @Resource
    private LogInfoService logInfoService;

    // 分页
    @PostMapping("page")
    public ResponseResult logsPage(@RequestBody LogsPageDTO logsPageDTO){
        log.info("日志分页:{}",logsPageDTO);
        return logInfoService.logsPage(logsPageDTO);
    }


    // 批量删除
    @DeleteMapping("delete")
    public ResponseResult deleteLogs(@RequestBody List<Integer> ids){
        log.info("批量删除日志:{}",ids);
        logInfoService.removeByIds(ids);
        return  ResponseResult.success();
    }
    // 导出日志
    @PostMapping("export")
    public void exportLogs(@RequestBody LogsExportDTO logsExportDTO, HttpServletResponse response){
        log.info("导出日志:{}",logsExportDTO);
        logInfoService.exportLogs(logsExportDTO,response);
    }

}
